package com.bookstore.bauhinia.service.impl;

import com.bookstore.bauhinia.mapper.UserMapper;
import com.bookstore.bauhinia.pojo.User;
import com.bookstore.bauhinia.pojo.UserExample;
import com.bookstore.bauhinia.service.AuthService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class AuthServiceImpl implements AuthService {
    @Resource
    private UserMapper userMapper;

    @Override
    public List<User> getUserByEmail(String email){
        UserExample example = new UserExample();
        UserExample.Criteria criteria = example.createCriteria();
        criteria.andEmailEqualTo(email);
        return userMapper.selectByExample(example);
    }

    @Override
    public boolean insertUser(User user){
        int id = userMapper.insertSelective(user);
        if(id > 0){
            return true;
        }
        return false;
    }
}
